package com.mrjy.integral.controller;

import com.mrjy.common.entity.SignUpGraphicInfo;
import com.mrjy.common.entity.UserInfo;
import com.mrjy.common.enums.ResultEnum;
import com.mrjy.common.exception.InnerException;
import com.mrjy.common.util.GlobalConstant;
import com.mrjy.integral.bo.ISignUpGraphicInfoBo;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

@Controller
@RequestMapping("integral/signupGraphicInfo")
public class SignupGraphicController {
    @Resource
    private ISignUpGraphicInfoBo signUpGraphicInfoBo;

    /**
     * 添加
     *
     * @return
     */
    @RequestMapping("/add")
    @ResponseBody
    public Object add(SignUpGraphicInfo info) {
        return signUpGraphicInfoBo.txInsert(info);
    }

    /**
     * 根据ID查询
     *
     * @return
     */
    @RequestMapping("/queryById")
    @ResponseBody
    public Object queryById(int schoolId) {
        return signUpGraphicInfoBo.queryById(schoolId);
    }

    /**
     * 修改
     *
     * @param userInfo
     * @return
     */
    @RequestMapping("/edit")
    @ResponseBody
    public Object edit(SignUpGraphicInfo info) {
        return signUpGraphicInfoBo.txUpdateById(info);
    }

    /**
     * 删除
     *
     * @param ids
     * @return
     */
    @RequestMapping("/deleteByIds")
    @ResponseBody
    public Object deleteByIds(int[] ids) {
        return signUpGraphicInfoBo.deleteByIds(ids);
    }

    /**
     * 禁用、起用
     *
     * @param ids
     * @return
     */
    @RequestMapping("/updateDisableFlag")
    @ResponseBody
    public Object updateDisableFlag(SignUpGraphicInfo info) {
        return signUpGraphicInfoBo.updateDisableFlag(info);
    }


    /**
     * 列表
     *
     * @return
     */
    @RequestMapping("/listPage")
    @ResponseBody
    public Object listPage(SignUpGraphicInfo info) {
        return signUpGraphicInfoBo.listPage(info);
    }

    /**
     * 列表
     *
     * @return
     */
    @RequestMapping("/selectTodayGraphic")
    @ResponseBody
    public Object selectTodayGraphic(SignUpGraphicInfo info, HttpSession session) {
        return signUpGraphicInfoBo.selectTodayGraphic(info, session);
    }

    /**
     * 导出
     *
     * @param ids
     * @return
     */
    @RequestMapping("/export")
    @ResponseBody
    public Object export(SignUpGraphicInfo info, HttpSession session, HttpServletResponse response) {
        UserInfo loginUser = (UserInfo) session.getAttribute(GlobalConstant.USER_INFO);
        if (null == loginUser) {
            throw new InnerException(ResultEnum.NOT_LOGIN);
        }
        return signUpGraphicInfoBo.export(info, response);
    }

    /**
     * 更新添加数
     *
     * @return
     */
    @RequestMapping("/addSaveNum")
    @ResponseBody
    public Object addSaveNum(SignUpGraphicInfo info) {
        return signUpGraphicInfoBo.txAddSaveNum(info);
    }

    /**
     * 更新编辑数
     *
     * @return
     */
    @RequestMapping("/addEditNum")
    @ResponseBody
    public Object addEditNum(SignUpGraphicInfo info) {
        return signUpGraphicInfoBo.txAddEditNum(info);
    }
}
